package com.hq.fxh.No5_User.Jianli;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hq.fxh.Modle.GetJianLiEduModle;
import com.hq.fxh.Modle.GetJianLiWorkModle;
import com.hq.fxh.Modle.JianLiWorkModle;
import com.hq.fxh.R;
import com.hq.fxh.Utils.DensityUtils;
import com.hq.fxh.Utils.Tool;

import java.util.List;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/21
 * @Email xlwenhao1858@sina.com
 */


public class JianLi_WorkAdapter extends BaseAdapter {
    List<JianLiWorkModle > data;

    public void setData(List<JianLiWorkModle> data) {
        this.data = data;
    }

    @Override
    public int getCount() {
        return data == null ? 0 : data.size();
    }

    @Override
    public Object getItem(int i) {
        return data.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder viewHolder = null;
        if (view == null || !(view.getTag() instanceof ViewHolder)) {
            view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_jianli_simplework, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }
        Tool.setStringToText(viewHolder.itemMyjianliName, data.get(i).getCompany_name());
        String getEnd_dt = data.get(i).getStart_dt()+"-"+ data.get(i).getEnd_dt() ;


        Tool.setStringToText(viewHolder.itemMyjianliTime, getEnd_dt);


        return view;
    }

    class ViewHolder {
        protected TextView itemMyjianliName;
        protected TextView itemMyjianliTime;

        ViewHolder(View rootView) {
            initView(rootView);
        }

        private void initView(View rootView) {
            itemMyjianliName = (TextView) rootView.findViewById(R.id.item_myjianli_Name);
            itemMyjianliTime = (TextView) rootView.findViewById(R.id.item_myjianli_Time);
        }
    }
}
